(function () {
    var tags={
        logout:tag.input("button","注销").click(function () {
            myAjax("get","logout.do","",function () {
                window.location.reload();
            })
        })
    };
    var fn={};
    var win=new Win();
    //顶部状态栏 名字 关闭按钮
    (function () {
        var status=tag.div().mst("w100%;h30;bg#ccc").attr("class","asWindow");
        win.append(status);

        //名字
        var img=$("<img src='data/app/setting/images/icon.png'>")
            .mst("fl;w20;h20;m5");
        var name=tag.span().html("设置").mst("fl;mt4;ml6");
        status.append(img,name);

        //关闭按钮
        var close=tag.canvas().attr({
            "width":"30",
            "height":"30"
        }).mst("bgrgba(0,0,0,0);fr;cup;tr300")
            .hover
            (
                function () {
                    $(this).mst("bg#f00");
                    drawClose(true);
                },
                function () {
                    $(this).mst("bgrgba(0,0,0,0)");
                    drawClose(false);
                })
            .click
            (
                function () {
                    win.remove();
                }
            );
        var o=close[0].getContext("2d");
        function drawClose(isHover) {
            o.clearRect(0,0,30,30);
            o.beginPath();
            o.moveTo(8,8);
            o.lineTo(22,22);
            o.moveTo(8,22);
            o.lineTo(22,8);
            isHover?o.strokeStyle="#fff":o.strokeStyle="#333";
            o.stroke();
        }
        drawClose(false);
        status.append(close);

    })();
    //侧边栏
    (function () {
        var box=tag.div().mst("bg#ddd;w220;h100%;fl;por").attr("class","asWindow");
        var st="h40;lh40;tac;cup";
        var tgt=tag.div().mst("bgrgba(0,0,0,0.3);poa;w100%;t0;l0;tr200;"+st);
        var userSet=tag.div().mst(st).html("帐 户 设 置").click(function () {
            tgt.mst("t0");
            fn.showUserSet();
        });
        var sysSet=tag.div().mst(st).html("系 统 设 置").click(function () {
            tgt.mst("t40");
            fn.showSysSet();
        });
        box.append(userSet,sysSet,tgt);
        win.append(box);
    })();
    //内容区
    (function () {
        var bst="w780;h620;ofh;tr300";

        //user set box,system set box
        var usb=tag.div().mst(bst);
        (function () {
            usb.append(tags.logout);
        })();
        //系统设置
        var ssb=tag.div().mst(bst);
        (function(){
            ssb.html(tag.input("button","伪装模式").click(function () {
                $("body").mst("bgiurl('data/app/music/images/desk.png');bgs100% 100%");
            }));
        })();

        var box=tag.div().mst("fl;por");
        win.append(box);

        box.append(usb,ssb);
        fn.showUserSet=function () {
            usb.mst("h620");
            ssb.mst("h0");
        };
        fn.showSysSet=function () {
           ssb.mst("h620");
           usb.mst("h0");
        };
        fn.showUserSet();
    })();

})();